//AQICN 客户端文件​
// clients/aqicnClient.js
const axios = require('axios');

class AQICNClient {
  constructor(token) {
    this.token = token;
    this.baseURL = 'https://api.waqi.info';
  }

  async getAirQuality(lat, lon) {
    try {
      const response = await axios.get(`${this.baseURL}/feed/geo:${lat};${lon}/`, {
        params: {
          token: this.token
        }
      });
      return response.data.data;
    } catch (error) {
      throw new Error(`AQICN API 请求失败: ${error.message}`);
    }
  }
}

module.exports = AQICNClient;